<?php


/**
* Puree CMS
* http://www.molotsoft.ru
*
* @package Puree_CMS
* @subpackage Admin/Views
* @author Ivan Chistyakov <ivan@molotsoft.ru>
* @version $Id: admin_view.ctp 1512 2010-04-21 13:10:21Z molotsoft@gmail.com $
* @link $HeadURL: http://puree-cms.googlecode.com/svn/trunk/plugins/admin/views/automate/admin_view.ctp $
*/


// scripts
echo $javascript->link('/admin/js/jquery_plugins/jquery.flash_message.js');
echo $javascript->link('/admin/js/jquery_plugins/jquery.button.js');
echo $javascript->link('/admin/js/jquery_plugins/jquery.form_tabs.js');
echo $javascript->link('/admin/js/automate/admin_view.js');

// form_container
echo '<div class="form form_container">';
if ($creating) {
	if (isset($is_tree, $parent_id) && $is_tree) {
		$add_url = array('action' => 'add', $parent_id, 'autoPage' => TRUE);
	} elseif (isset($has_rubric, $rubric_id) && $has_rubric) {
		$add_url = array('action' => 'add', $rubric_id, 'autoPage' => TRUE);
	} else {
		$add_url = array('action' => 'add', 'autoPage' => TRUE);
	}
	echo $form->create($model, array('id' => 'add', 'url' => $add_url, 'type' => 'file'));
} else {
	echo $form->create($model, array('id' => 'edit', 'url' => array('action' => 'edit', 'id' => $id, 'autoPage' => TRUE), 'type' => 'file'));
}

// form_caption
echo '<div class="form_caption">' . $caption_for_layout . '</div>';

// form_buttons (admin_view_buttons_add.ctp | admin_view_buttons_edit.ctp)
if ($creating) {
	echo $this->controllerElement('admin_view_buttons_add');
} else {
	echo $this->controllerElement('admin_view_buttons_edit');
}

// form_tabs
echo '<div class="form_tabs">';

// form_tab_buttons
echo '<div class="form_tab_buttons">';
foreach ($tab_schema as $tab_name => $tab_description) {
	if ($tab_description['type'] === 'skip') {
		continue;
	}
	// form_tab_button-tab_name
	echo '<div class="form_tab_button form_tab_button-' . $tab_name . '">' . $routine->icon($tab_description['icon']) . ' <a href="#' . $tab_name . '">' . $tab_description['label'] . '</a></div>';
}
echo '</div>'; // end of form_tab_buttons

// form_tab_panels
echo '<div class="form_tab_panels">';
foreach ($tab_schema as $tab_name => $tab_description) {
	if ($tab_description['type'] === 'skip') {
		continue;
	}
	// form_tab_panel-tab_name (admin_view_tab_<tab_name>.ctp | admin_view_default_tab.ctp)
	//echo $this->controllerElement('admin_view_tab_' . $tab_description['type'], array('tab_name' => $tab_name, 'tab_description' => $tab_description));
	//echo $this->controllerElement('admin_view_default_tab', array('tab_name' => $tab_name, 'tab_description' => $tab_description));
	if (is_file(ELEMENTS . $controller . DS . 'admin_view_tab_' . $tab_description['type'] . $this->ext)) {
		echo $this->element($controller . DS . 'admin_view_tab_' . $tab_description['type'], array('tab_name' => $tab_name, 'tab_description' => $tab_description));
	} elseif (is_file(ELEMENTS . 'automate' . DS . 'admin_view_tab_' . $tab_description['type'] . $this->ext)) {
		echo $this->element('automate' . DS . 'admin_view_tab_' . $tab_description['type'], array('tab_name' => $tab_name, 'tab_description' => $tab_description));
	} elseif (is_file(ELEMENTS . $controller . DS . 'admin_view_default_tab' . $this->ext)) {
		echo $this->element($controller . DS . 'admin_view_default_tab', array('tab_name' => $tab_name, 'tab_description' => $tab_description));
	} elseif (is_file(ELEMENTS . 'automate' . DS . 'admin_view_default_tab' . $this->ext)) {
		echo $this->element('automate' . DS . 'admin_view_default_tab', array('tab_name' => $tab_name, 'tab_description' => $tab_description));
	}
}
echo '</div>'; // end of form_tab_panels

echo '</div>'; // end of form_tabs

// form_buttons (admin_view_buttons_add.ctp | admin_view_buttons_edit.ctp)
if ($creating) {
	echo $this->controllerElement('admin_view_buttons_add');
} else {
	echo $this->controllerElement('admin_view_buttons_edit');
}

echo $form->end();
echo '</div>'; // end of form_container


?>